package org.bzjj.servlet.bean.ctrl;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Service;
import org.bzjj.jg.TmriOutAccessSoapBindingStub;

public class TuiBan {

	public static String url = "http://172.18.16.213:9080/pnweb/services/TmriOutAccess";
	private TmriOutAccessSoapBindingStub stub = null;

	private void ensureStub() throws MalformedURLException, AxisFault {
		if (stub == null) {
			String webserviceURL = url;
			URL url = new URL(webserviceURL);
			Service service = new Service();
			stub = new TmriOutAccessSoapBindingStub(url, service);
		}
	}

	public String doQuery(String jylsh, String hphm, String hpzl) throws Exception {
		this.ensureStub();
		String result = "";
		String encrptXmlDoc = "<?xml version=\"1.0\" encoding=\"GBK\"?>\n<root>" + "\n<vehispara>\n<jylsh>" + jylsh
				+ "</jylsh>\n<jyjgbh>" + jyjg[Integer.valueOf(jylsh.substring(0, 2))] + "</jyjgbh>\n<hphm>" + hphm
				+ "</hphm>\n<hpzl>" + hpzl + "</hpzl>\n</vehispara>\n</root>";
		String jkxlh = "7F19090902041704001589CB869D8A878CDAE8DD8ED8EE848AA7ABC7D5CEDAB2C8EDBCFE";

		result = stub.writeObjectOut("18", jkxlh, "18C72", encrptXmlDoc);
		try {
			result = URLDecoder.decode(result, "utf-8");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return result;
	}

	public static String[] jyjg = { "0000000000", "3716000011", "3700000673", "3716000010", "3716000008", "3716000006",
			"3700000682", "3700000697", "3700000679", "3700000674", "3700000672", "3716000001", "3716000009",
			"3700000784", "3716000002", "3716000003", "3716000004", "3700000680", "3716000013", "3716000014",
			"3716000016", "3716000027", "3716000028", "3716000029", "3716000032", "3716000033", "3716000034",
			"3716000035", "3716000036", "3716000038", "3716000039", "3716000041", "3716000043", "3716000044",
			"3716000045", "3716000046", "3716000047", "3716000048", "3716000050", "3716000049" };

}
